-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flatpak] Capture details about branch #3406
[flatpak] Capture details about branch #3406
Conversation
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
pkg = line.split() | ||
name, version = pkg[0], pkg[1] | ||
yield (name, version, None) | ||
for line in pkg_list.splitlines()[1:]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the [1:]
? The flatpak list
does not start with a header, the very first line already contains a package - at least in my case..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does in my case, but if I recall correctly, the output is different when called from sos, and there's no header there. I've fixed this in the next version.
name, branch = pkg[0], pkg[2] | ||
if not pkg[1]: | ||
version = '' | ||
else: | ||
version = pkg[1] | ||
yield (name, version, branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simple yield (pkg[0], pkg[1], pkg[2])
? (maybe worth checking len(pkg)>2
, just in case of truncated output (or that is over-paranoic..?))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try this and see if it covers the empty version case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking the length of pkg and then yielding either pkg[1] or None seems better than just yielding pkg[1] regardless of it being there or not:
if len(pkg) > 2:
yield (pkg[0], pkg[1], pkg[2])
else:
yield (pkg[0], None, pkg[2])
Unless yielding pkg[1] when doesn't exist changes it to None on the yield, which then may simply the code a lot. But I saw in the other sources in package_managers that we explicitly set to None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I am not sure now if the split
returns None
or empty string. But can we pass None
as version? Does not we expect a string value later on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on I'm not sure, but if that's the case, we can fail back to "" instead of None. Let me see if I can test with packages with empty value and see what happens with None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, split
returns empty string and not None
(which is in fact obvious, it returns list of strings):
>>> "name\tvers\tbranch".split("\t")
['name', 'vers', 'branch']
>>> "name\t\tbranch".split("\t")
['name', '', 'branch']
>>>
And as far as I checked, we assume strings there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I just checked what we get with yield (pkg[0], pkg[1], pkg[2]) without checking pkg lenght, from _generate_pkg_list, and it is an empty string. So just that line should be enough.
Gather details about branch, so it complements the version number (which can be empty sometimes). Fixes: sosreport#3404 Signed-off-by: Jose Castillo <[email protected]>
bacc258
to
340ed41
Compare
Gather details about branch, so it complements
the version number (which can be empty sometimes).
Fixes: #3404
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines